package com.zmyuan.demo.netty.thrift.rpc;

import com.zmyuan.demo.netty.thrift.HelloWorldService;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;

/**
 * Created by zdb on 2017/2/17.
 */
public class TNonBlockThriftRPCClient {

    public static void startClient(int port) throws TException {
        TTransport tTransport = new TFramedTransport(new TSocket("localhost", port));
        TProtocol protocol = new TBinaryProtocol(tTransport);
        HelloWorldService.Client client = new HelloWorldService.Client(protocol);

        tTransport.open();
        String result = client.sayHello("zhudebin");
        System.out.println(result);
    }

    public static void main(String[] args) throws TException {
        startClient(8999);
    }
}
